
encode country, gen(country_enc)
order country_enc, after(country)

**Electoral system*
gen incentives=1
gen median=0
gen mean=0

replace incentives=0 if country=="Benin"
replace incentives=0 if country=="Uruguay"
replace median=3 if country=="Benin"
replace median=10 if country=="Brazil"
replace median=2 if country=="Chile" & year<2017
replace median=5 if country=="Chile" & year>2017
replace median=7 if country=="Indonesia"
replace median=1 if country=="Kenya"
replace median=1 if country=="Malawi"
replace median=1 if country=="Philippines"
replace median=8 if country=="Sri Lanka"
replace median=2 if country=="Uruguay"

replace mean=3.46 if country=="Benin"
replace mean=19 if country=="Brazil"
replace mean=2 if country=="Chile" & year<2017
replace mean=5.54 if country=="Chile" & year>2017
replace mean=7.16 if country=="Indonesia"
replace mean=1 if country=="Kenya"
replace mean=1 if country=="Malawi"
replace mean=1 if country=="Philippines"
replace mean=8.90 if country=="Sri Lanka"
replace mean=5.21 if country=="Uruguay"


destring LR_position_president, ignore("NA") replace

drop if inlist(portfolio, ///
  "Vice President",       ///
  "Vice Presidency",      ///
  "Presidency",           ///
  "President",            ///
  "Prime Minister")


encode gender_portfolio, gen(gender)
order gender, after(gender_portfolio)

foreach var of varlist *shadowing*{
  capture: confirm string var `var'
  if (_rc == 0) replace `var' = "0" if `var' == "n/a"
}
destring *shadowing*, replace ignore("NA")

replace prestige = "Low" if prestige == "NA"
label define prestige 1 "Low" 2 "Medium" 3 "High"
encode prestige, gen(prestige_enc) label(prestige) noextend

destring distance_coalition_mean, ignore("NA") replace
replace distance_coalition_mean = . if (distance_coalition_mean > 20)

destring distance_president, ignore("NA") replace
replace distance_president = . if (distance_president > 20)

egen government = group(country year)
gen distance_coalition_mean_log = ln(distance_coalition_mean + 0.001)
gen distance_president_log = ln(distance_president + 0.001)

*Generate three outcomes
*
*gen presidential_shadowing = ///
*  presidentialshadowing01 == 1 & partisanshadowing01 == 0

*gen partisan_shadowing = ///
*  presidentialshadowing01 == 0 & partisanshadowing01 == 1

gen noshadow = !shadowing

*tab1 presidential_shadowing partisan_shadowing noshadow

local predict ///
  predict(outcome(presidential_shadowing)) ///
  predict(outcome(partisan_shadowing))

gen latam=1
replace latam=0 if country=="Benin"
replace latam=0  if country=="Indonesia"
replace latam=0  if country=="Kenya"
replace latam=0  if country=="Malawi"
replace latam=0 if country=="Philippines"
replace latam=0  if country=="Sri Lanka"

*gen shadowing = (presidentialshadowing01 * 1) + (partisanshadowing01 * 2)
*replace shadowing = . if shadowing == 3
*/
